<template>
    <el-popconfirm title="确定要撤回发起的审批么?" @confirm="submitForm">
        <template #reference>
            <el-link type="warning" :loading="loading"> 撤回 </el-link>
        </template>
    </el-popconfirm>
</template>
  
<script lang="ts" setup>
import { ref,watch } from 'vue'
import { ElMessage } from 'element-plus'
import http from '../util/request';
const loading = ref<boolean>(false)
interface RuleForm {
    source_id: number|string
    model: string
    source: string
} 
const ruleForm = ref<RuleForm>({
    source_id: 0,
    source:'',
    model: '',
})

const props = defineProps<{
    id:number|string
    model:string
    source:string
}>()

watch(props,()=>{
    ruleForm.value.source_id = props.id
    ruleForm.value.source = props.source
    ruleForm.value.model = props.model
},{ immediate: true })

const submitForm = (async () => {
    loading.value = true
    http.patch('/approve/revoke',ruleForm.value).then((response:any)=>{
        loading.value = false
        if(response.data.code != 200){
            ElMessage.error(response.data.msg);return
        }
        ElMessage.success(response.data.msg);
    })
})

</script>
<style scoped>
</style>
